from flask import Flask, session
from flask_sqlalchemy import SQLAlchemy
from redis import StrictRedis
from flask_wtf.csrf import CSRFProtect
from flask_session import Session
from config import config_dict
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

from info import create_app, db
# class Config(object):
#     DEBUG = True
#     SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/news_public"
#     SQLALCHEMY_TRACK_MODIFICATIONS = True
#     REDIS_HOST = "127.0.0.1"
#     REDIS_PORT = 6379
#     SESSION_TYPE = "redis"
#     SESSION_REDIS = StrictRedis(REDIS_HOST, port=REDIS_PORT)
#     SESSION_USE_SIGNER = True
#     SESSION_PERMANENT = False
#     PERMANENT_SESSION_LIFETIME = 86400
#     SECRET_KEY = "ASJDLKFLJDSOJFOSAJLJSDK"


# app = Flask(__name__)
# config_class = config_dict["development"]
# app.config.from_object(config_class)
# db = SQLAlchemy(app)
#
# redis_store = StrictRedis(host=config_class.REDIS_HOST, port=config_class.REDIS_PORT)
# CSRFProtect(app)
#
# Session(app)

app = create_app("development")

manager = Manager(app)

Migrate(app, db)
manager.add_command("db", MigrateCommand)


if __name__ == '__main__':
    # app.run()
    manager.run()
